	function Pie(canvasId,data = {}){
		 this.data = data;
		 this.canvas = document.getElementById(canvasId);
		 this.ctx = this.canvas.getContext('2d');
		 var height = this.canvas.height;
		 var width = this.canvas.width;
		 this.ctx.translate(height/2,width/2);
		 //初始值 圆半径 R
		 var R,percentage,radian;
		 R = (height>width)?width:height;
		 this.R = R/2-90;;
		 
		 var total = 0;
		 for(var i = 0; i< this.data.length; i++ ){
			total += this.data[i]['value'];
		 }
		 var curRadian = 0;
		 for( var i = 0; i< this.data.length;i++){
			this.data[i]['percentage'] = this.data[i]['value']/total;
			this.data[i]['radian'] = 2*Math.PI*this.data[i]['percentage'];
			this.data[i]['innerText'] = this.data[i]['percentage'].toFixed(4)*100 + '%';
			this.data[i]['beginRadian'] = curRadian;
			curRadian += this.data[i]['radian'];
		 }
		 
		 console.log(this.data);
		 
	}
	
	Pie.prototype.drawPie = function(){
		for(var i = 0;i< this.data.length; i++ ){
			this.drawArc({
				R:this.R,
				radian:this.data[i]['radian'],
				beginRadian:this.data[i]['beginRadian'],
				innerText:this.data[i]['innerText'],
				outText:this.data[i]['outText'],
				fillStyle:this.data[i]['fillStyle'],
				lineStyle:this.data[i]['lineStyle'],
				innerWordStyle:this.data[i]['innerWordStyle'],
				outWordStyle:this.data[i]['outWordStyle'],
			});
		}
	}
	
	Pie.prototype.drawArc = function(param){
	//默认值
		 var option = {
			R:this.R,
			radian:0,
			beginRadian:0,
			innerText:'20%',
			outText:'Ebike',
			innerDistance:-50,
			outDistance:20,
			strokeStyle:'white',
			fillStyle:'#ffa30a',
			lineStyle:'red',
			innerWordStyle:'yellow',
			outWordStyle:'green',
			levelLineLenght:10
		 };
		 //合并参数
		 for( var k in option ){
			if("undefined" == typeof param[k]){
				 param[k] = option[k];
			}
		 }
		 console.log(param);
		 
		 var rLine = param.R+param.outDistance;
		 var rWord = param.R+param.innerDistance;	 
		 var wordPosition = {x:0,y:0};
		 wordPosition.x = rWord*Math.cos(0.5*param.radian+param.beginRadian);
		 wordPosition.y = rWord*Math.sin(0.5*param.radian+param.beginRadian);
		 
		 var linePosition = [{x:0,y:0},{x:0,y:0},{x:0,y:0}];//begin,middle,end
		 linePosition[0].x = param.R*Math.cos( 0.5*param.radian + param.beginRadian );
		 linePosition[0].y = param.R*Math.sin( 0.5*param.radian + param.beginRadian );
		 linePosition[1].x = rLine*Math.cos( 0.5*param.radian + param.beginRadian );
		 linePosition[1].y = rLine*Math.sin( 0.5*param.radian + param.beginRadian );
		 
		 linePosition[2].x = (Math.abs(linePosition[1].x)+param.levelLineLenght)*(linePosition[1].x/Math.abs(linePosition[1].x));//加和减根据象限来确定
		 linePosition[2].y = linePosition[1].y;
		 
		 //画弧线
		 this.ctx.beginPath();
		 this.ctx.moveTo(0,0);
		 this.ctx.strokeStyle = param.strokeStyle; 
		 this.ctx.fillStyle= param.fillStyle;
		 this.ctx.arc(0,0,param.R,param.beginRadian,param.radian+param.beginRadian);
		 this.ctx.fill();
		 this.ctx.stroke();
		 this.ctx.closePath();  
		 
		 //折线
		 this.ctx.beginPath();
		 this.ctx.moveTo(linePosition[0].x,linePosition[0].y);
		 this.ctx.strokeStyle=param.lineStyle;
		 this.ctx.lineTo(linePosition[1].x,linePosition[1].y);
		 this.ctx.lineTo(linePosition[2].x,linePosition[2].y);
		 this.ctx.stroke();
		 
		 //文字
		 this.ctx.strokeStyle=param.innerWordStyle;
		 this.ctx.strokeText(param.innerText,wordPosition.x,wordPosition.y);
		 this.ctx.strokeStyle=param.outWordStyle;
		 if(linePosition[2].x < 0){
			linePosition[2].x = linePosition[2].x - this.ctx.measureText(param.outText).width - 2;
			console.log(linePosition[2]);
		 }else{
			linePosition[2].x = linePosition[2].x + 2;
		 }
		 this.ctx.strokeText(param.outText,linePosition[2].x,linePosition[2].y);
	}